package com.sgb.goods.entity;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.contrarywind.interfaces.IPickerViewData;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.List;

/**
 * 描述：商品发布、商品询价-装车、卸车相关实体类
 *
 * @author qiangHeNooo
 * <p>
 * 时间：2021.10.29
 */
public class GoodsInfoTypeEntity implements IPickerViewData, Serializable, Parcelable {

    @SerializedName(value = "no", alternate = {"id"})
    private String no;
    @SerializedName(value = "name", alternate = {"distance"})
    private String name;
    /**
     * 车型图用
     */
    private String typeImg;
    /**
     * 后台配置 物流首页金刚区显示图
     */
    private String kingKongDiagram;
    /**
     * 获取车型关联车长接口时使用
     */
    private List<GoodsInfoTypeEntity> carLenList;

    public GoodsInfoTypeEntity() {
    }

    public GoodsInfoTypeEntity(String no, String name) {
        this.no = no;
        this.name = name;
    }

    protected GoodsInfoTypeEntity(Parcel in) {
        no = in.readString();
        name = in.readString();
        typeImg = in.readString();
        kingKongDiagram = in.readString();
        carLenList = in.createTypedArrayList(GoodsInfoTypeEntity.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {

        parcel.writeString(no);
        parcel.writeString(name);
        parcel.writeString(typeImg);
        parcel.writeString(kingKongDiagram);
        parcel.writeTypedList(carLenList);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<GoodsInfoTypeEntity> CREATOR = new Creator<GoodsInfoTypeEntity>() {
        @Override
        public GoodsInfoTypeEntity createFromParcel(Parcel in) {
            return new GoodsInfoTypeEntity(in);
        }

        @Override
        public GoodsInfoTypeEntity[] newArray(int size) {
            return new GoodsInfoTypeEntity[size];
        }
    };

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTypeImg() {
        return typeImg;
    }

    public void setTypeImg(String typeImg) {
        this.typeImg = typeImg;
    }

    public List<GoodsInfoTypeEntity> getCarLenList() {
        return carLenList;
    }

    public void setCarLenList(List<GoodsInfoTypeEntity> carLenList) {
        this.carLenList = carLenList;
    }

    public String getKingKongDiagram() {
        return kingKongDiagram;
    }

    public void setKingKongDiagram(String kingKongDiagram) {
        this.kingKongDiagram = kingKongDiagram;
    }

    @Override
    public String getPickerViewText() {
        return name;
    }


    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof GoodsInfoTypeEntity) {
            return no.equals(((GoodsInfoTypeEntity) obj).getNo());
        }
        return false;

    }

    @Override
    public int hashCode() {
        return TextUtils.isEmpty(no) ? "".hashCode() : no.hashCode();
    }
}
